package com.runa.monitor.platinterface.config;

import io.grpc.ServerBuilder;
import lombok.extern.slf4j.Slf4j;
import org.lognet.springboot.grpc.GRpcServerBuilderConfigurer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 2024/6/24 16:53
 * zhangYB
 */
@Slf4j
@Configuration
public class GrpcServerBuilderConfig extends GRpcServerBuilderConfigurer {


    @Override
    public void configure(ServerBuilder<?> serverBuilder) {
        serverBuilder
                // 设置最大消息大小为16MB
                .maxInboundMessageSize(Integer.MAX_VALUE)
                // 设置最大的请求大小为16MB
                .maxInboundMessageSize(Integer.MAX_VALUE);
    }

//    @Value("${grpc.port}")
//    private Integer port;
//
//    @Bean
//    public ServerBuilder<?> gRpcServerBuilder() {
//        log.info("初始化gRpcServerBuilder...");
//        ServerBuilder<?> serverBuilder = ServerBuilder.forPort(port)
//                // 设置最大消息大小为16MB
//                .maxInboundMessageSize(Integer.MAX_VALUE)
//                // 设置最大的请求大小为16MB
//                .maxInboundMessageSize(Integer.MAX_VALUE);
//        return serverBuilder;
//    }



}
